package game.views;

import hx.display.HBox;

/**
 * 角色标签显示组件
 */
@:build(hx.macro.UIBuilder.build("assets/views/RoleTags.xml"))
class RoleTags extends HBox {
	/**
	 * 设置标签数据
	 * @param tags 
	 */
	public function setData(tags:Array<String>, flip:Bool = false):Void {
		if (tags != null) {
			this.visible = true;
			for (i in 0...4) {
				var tagDisplay:Tag = cast this.getChildById("tag" + ((flip ? 3 - i : i) + 1));
				tagDisplay.visible = false;
			}
			for (i => tag in tags) {
				if (i >= 4) {
					break;
				}
				var tagDisplay:Tag = cast this.getChildById("tag" + ((flip ? 3 - i : i) + 1));
				tagDisplay.tagLabel.data = tag;
				tagDisplay.visible = true;
			}
		} else {
			this.visible = false;
		}
	}
}
